const http = require('http');

// 使用获取到的token测试催款记录API
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxLCJuYW1lIjoiYWRtaW4iLCJyb2xlIjoiYWRtaW4ifSwiaWF0IjoxNzYzMjEyOTcxLCJleHAiOjE3NjMyOTkzNzF9.8gdz0mvtOJwI2WLCh7Utl_BkOTURyGdQiLPbzG4QtHY';

const options = {
  hostname: 'localhost',
  port: 9001,
  path: '/api/v1/collection-records?page=1&limit=20',
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
};

const req = http.request(options, (res) => {
  let data = '';
  
  res.on('data', (chunk) => {
    data += chunk;
  });
  
  res.on('end', () => {
    console.log('催款记录API响应:');
    console.log('状态码:', res.statusCode);
    console.log('响应数据:');
    
    try {
      const response = JSON.parse(data);
      console.log('解析后的响应:', JSON.stringify(response, null, 2));
      
      if (response.data && response.data.list) {
        console.log(`获取到 ${response.data.list.length} 条催款记录`);
      }
    } catch (error) {
      console.error('解析响应出错:', error);
      console.log('原始响应数据:', data);
    }
  });
});

req.on('error', (error) => {
  console.error('请求出错:', error);
});

req.end();